package com.learn.my;

import java.util.concurrent.*;

public class Test008 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService= Executors.newFixedThreadPool(4);
        Future<String> submit = executorService.submit(new TaskCallable());
        System.out.println("主线程开始工作");
        String result=submit.get();
        System.out.println("result:"+result);
    }
}

class TaskCallable implements Callable<String>{

    @Override
    public String call() throws Exception {
        System.out.println("子线程开始工作");
        Thread.sleep(5000);
        System.out.println("子线程等待5s完毕");
        return "小工";
    }
}
